// pages/carts/carts.js
const cartsPage = require("../../models/carts")
Page({
  data: {
    value:[]
  },
  onLoad: async function (options) {
    var res = await cartsPage();
    var value = res.data;
    this.setData({
      value,
    });
    console.log('this.value: ',  this.data.value);
  },
  onStep(event){
    console.log(event.detail);
    this.data.value.forEach(res=>{
      if(event.currentTarget.dataset.id==res.id){
        res.productCount = event.detail;
      }
    });
    this.setData({
      value:this.data.value
    })
  },
  onChange(event){
    console.log(event.detail);
    this.data.value.forEach(res=>{
      if(event.currentTarget.dataset.id==res.id){  
        res.isSelected = event.detail;
      }
    });
    this.setData({
      value:this.data.value
    })
  },
  onChangeAll(event){
    this.data.value.forEach(res=>{  
        res.isSelected = event.detail;
    });
    this.setData({
      value:this.data.value
    })
  }
})